var express = require('express');
var router = express.Router();
const { salesmansAdd, salesmansRend, salesmansUpdata, salesmansModifyById, getSalesmansDeleteById, receiveSalesmanById } = require('../service/salesmansService')
/* GET home page. */
//新增销售员
router.post('/salesmansAdd', async function (req, res, next) {


   res.send(await salesmansAdd(req.body));

})
//获取销售员
router.get('/salesmansRend', async function (req, res, next) {

   res.send(await salesmansRend(req.query));
})

//通过_id获取销售员
router.post('/salesmansUpdata', async function (req, res, next) {
   const data = await salesmansUpdata(req.body)
   console.log(1111111, data);
   res.send(data);
})

//通过_id修改销售员信息
router.post('/salesmansModifyById', async function (req, res, next) {

   res.send(await salesmansModifyById(req.body));

})
//通过_id删除销售员
router.post('/getSalesmansDeleteById', async function (req, res, next) {

   res.send(await getSalesmansDeleteById(req.body));

})

//-------------------------------------胡兴泽
//由id来获取销售员
router.get('/receiveSalesmanById',async function (req, res, next) {
   const result = await receiveSalesmanById(req.query._id);
   res.send(result);
})
module.exports = router;
